import 'package:cat_eye/base/base_refresh_state.dart';
import 'package:cat_eye/root_page/home_page/hom_video_page_widget.dart';
import 'package:cat_eye/root_page/home_page/video_details_widget.dart';
import 'package:cat_eye/util/util.dart';
import 'package:cat_eye/view_model/hot_view_model/hot_list_view_model.dart';
import 'package:flutter/material.dart';

/*
* @Package: root_page.hot_page
* @ClassName: hot_list_widget
* @Author: szj
* @CreateDate: 8/4/21 1:58 PM
* TODO 热门 列表
*/
class HotListWidget extends StatefulWidget {
  final url;

  const HotListWidget({Key key, @required this.url}) : super(key: key);

  @override
  _HotListWidgetState createState() => _HotListWidgetState();
}

class _HotListWidgetState
    extends BaseRefreshState<HotListWidget, HotListViewModel> {
  @override
  // TODO: implement buildViewModel
  HotListViewModel get buildViewModel => HotListViewModel(widget.url);

  @override
  Widget buildWidget(BuildContext context, HotListViewModel model) {
    return ListView.builder(
        itemCount: model.itemList.length,
        itemBuilder: (BuildContext context, int index) {
          return InkWell(onTap:(){
            Navigator.push(context, router(widget: VideoDetailsWidget(data: model.itemList[index].data)));
          },child: HomeVideoPageWidget(video: model.itemList[index]));
        });
  }
}
